import { expect, test } from 'vitest';
import { checkStr, validatePwd } from '#check';
import {
  arrayTools,
  validate as checkType,
  cutDown,
  identify,
  num,
  str,
  urlToObj,
} from '#lib';

// 测试 validate 命名空间的导出
test('validate exports', () => {
  expect(checkType).toBeDefined();
  expect(typeof checkType.isString).toBe('function');
  expect(typeof checkType.isNumber).toBe('function');
  expect(typeof checkType.isBoolean).toBe('function');
  expect(typeof checkType.isFunction).toBe('function');
  expect(typeof checkType.isNull).toBe('function');
  expect(typeof checkType.isUndefined).toBe('function');
  expect(typeof checkType.isObj).toBe('function');
  expect(typeof checkType.isArray).toBe('function');
  expect(typeof checkType.isDate).toBe('function');
  expect(typeof checkType.isRegExp).toBe('function');
  expect(typeof checkType.isError).toBe('function');
  expect(typeof checkType.isSymbol).toBe('function');
  expect(typeof checkType.isPromise).toBe('function');
  expect(typeof checkType.isSet).toBe('function');
  expect(typeof checkType.isNaN).toBe('function');
  expect(typeof checkType.isFalse).toBe('function');
  expect(typeof checkType.isTrue).toBe('function');
  expect(typeof checkType.isIos).toBe('function');
  expect(typeof checkType.isPC).toBe('function');
  expect(typeof checkType.browserType).toBe('function');
  expect(typeof checkType.checkStr).toBe('function');
  expect(typeof checkType.isCardID).toBe('function');
  expect(typeof checkType.validatePwd).toBe('function');
});

// 测试 str 命名空间的导出
test('str exports', () => {
  expect(str).toBeDefined();
  expect(typeof str.camelToUnderline).toBe('function');
  expect(typeof str.underlineToCamel).toBe('function');
  expect(typeof urlToObj).toBe('function');
});

// 测试 arrayTools 命名空间的导出
test('arrayTools exports', () => {
  expect(arrayTools).toBeDefined();
  expect(typeof arrayTools.traverseTree).toBe('function');
  expect(typeof arrayTools.getTreeDepth).toBe('function');
  expect(typeof arrayTools.treeNodeToMap).toBe('function');
  expect(typeof arrayTools.findNodeById).toBe('function');
  expect(typeof arrayTools.filterTree).toBe('function');
  expect(typeof arrayTools.cloneTree).toBe('function');
  expect(typeof arrayTools.flattenTree).toBe('function');
  expect(typeof arrayTools.formatStdNode).toBe('function');
});

// 测试 checkStr 的导出
test('checkStr exports', () => {
  expect(checkStr).toBeDefined();
  expect(typeof checkStr).toBe('function');
});

// 测试 validatePwd 的导出
test('validatePwd exports', () => {
  expect(validatePwd).toBeDefined();
  expect(typeof validatePwd).toBe('function');
});

// 测试 num 命名空间的导出
test('num exports', () => {
  expect(num).toBeDefined();
  expect(typeof num.numberToChinese).toBe('function');
  expect(typeof num.numToCnReading).toBe('function');
  expect(typeof num.numToCn).toBe('function');
});

// 测试 timer 模块的导出
test('timer exports', () => {
  expect(cutDown).toBeDefined();
  expect(typeof cutDown).toBe('function');
});

// 测试 identify 模块的导出
test('identify exports', () => {
  expect(identify).toBeDefined();
  expect(typeof identify.generateId).toBe('function');
  expect(typeof identify.validateId).toBe('function');
  expect(typeof identify.Identify).toBe('function');
  expect(typeof identify.sexValue).toBe('object');
  expect(typeof identify.sexDesc).toBe('object');
});
